import request from '@/utils/request'

// 院系
export function addDept(data) {
  return request({
    url: '/dept/addDept',
    method: 'post',
    data
  })
}

export function updateDept(data) {
  return request({
    url: '/dept/updateDept',
    method: 'post',
    data
  })
}

export function deleteDept(deptID) {
  return request({
    url: '/dept/deleteDept',
    method: 'get',
    params: { deptID }
  })
}

export function getDepts(params) {
  return request({
    url: '/dept/getDepts',
    method: 'get',
    params
  })
}

// 纵向-项目类别
export function addProjectcate(data) {
  return request({
    url: '/Projectcate/addProjectcate',
    method: 'post',
    data
  })
}

export function updateProjectcate(data) {
  return request({
    url: '/Projectcate/updateProjectcate',
    method: 'post',
    data
  })
}

export function deleteProjectcate(projectcateID) {
  return request({
    url: '/Projectcate/deleteProjectcate',
    method: 'get',
    params: { projectcateID }
  })
}

export function getProjectCate(params) {
  return request({
    url: '/Xmlb/getPaperQulification',
    method: 'get',
    params
  })
}

// 纵向-项目来源
export function addProjectSourse(data) {
  return request({
    url: '/ProjectSourse/addProjectSourse',
    method: 'post',
    data
  })
}

export function updateProjectSourse(data) {
  return request({
    url: '/ProjectSourse/updateProjectSourse',
    method: 'post',
    data
  })
}

export function deleteProjectSourse(ID) {
  return request({
    url: '/ProjectSourse/deleteProjectSourse',
    method: 'get',
    params: { ID }
  })
}

export function getProjectSourse(params) {
  return request({
    url: '/ProjectSourse/getProjectSourse',
    method: 'get',
    params
  })
}

// 纵向-组织形式
export function addOrganizationForm(data) {
  return request({
    url: '/OrganizationForm/addorganizationFormService',
    method: 'post',
    data
  })
}

export function updateOrganizationForm(data) {
  return request({
    url: '/OrganizationForm/updateOrganizationForm',
    method: 'post',
    data
  })
}

export function deleteOrganizationForm(ID) {
  return request({
    url: '/OrganizationForm/deleteOrganizationForm',
    method: 'get',
    params: { ID }
  })
}

export function getOrganizationForm(params) {
  return request({
    url: '/OrganizationForm/getOrganizationForm',
    method: 'get',
    params
  })
}

// 纵向-活动类型
export function addActivityType(data) {
  return request({
    url: '/ActivityType/addactivityType',
    method: 'post',
    data
  })
}

export function updateActivityType(data) {
  return request({
    url: '/ActivityType/updateactivityType',
    method: 'post',
    data
  })
}

export function deleteActivityType(activityTypeID) {
  return request({
    url: '/ActivityType/deleteActivityType',
    method: 'get',
    params: { activityTypeID }
  })
}

export function getActivityType(params) {
  return request({
    url: '/ActivityType/getActivityType',
    method: 'get',
    params
  })
}

// 纵向-学科分类
export function addDisciplineClassfi(data) {
  return request({
    url: '/disciplineClassfi/addDisciplineClassfi',
    method: 'post',
    data
  })
}

export function updateDisciplineClassfi(data) {
  return request({
    url: '/disciplineClassfi/updateDisciplineClassfi',
    method: 'post',
    data
  })
}

export function deleteDisciplineClassfi(DisciplineClassfiID) {
  return request({
    url: '/disciplineClassfi/deleteDisciplineClassfi',
    method: 'get',
    params: { DisciplineClassfiID }
  })
}

export function getDisciplineClassfi(params) {
  return request({
    url: '/Zxxk/getPaperQulification',
    method: 'get',
    params
  })
}

// 论文-学科分类
export function getPaperDisciplineClassfi(params) {
  return request({
    url: '/lwkj/getLwkj',
    method: 'get',
    params
  })
}

// 咨询报告-一级学科
export function getConsultDisciplineClassfi(params) {
  return request({
    url: '/achievementSubject/SelectAll',
    method: 'get',
    params
  })
}

// 咨询报告-一级学科
export function getSourceDisciplineClassfi(params) {
  return request({
    url: '/achievementSource/SelectAll',
    method: 'get',
    params
  })
}

// 纵向-服务的国民经济行业
export function addNationalEconomy(data) {
  return request({
    url: '/NationalEconomy/addNationalEconomy',
    method: 'post',
    data
  })
}

export function updateNationalEconomy(data) {
  return request({
    url: '/NationalEconomy/updateNationalEconomy',
    method: 'post',
    data
  })
}

export function deleteNationalEconomy(ID) {
  return request({
    url: '/NationalEconomy/deleteNationalEconomy',
    method: 'get',
    params: { ID }
  })
}

export function getNationalEconomy(params) {
  return request({
    url: '/NationalEconomy/getNationalEconomy',
    method: 'get',
    params
  })
}

// 纵向-项目的社会经济目标
export function addSocialEconomy(data) {
  return request({
    url: '/SocialEconomy/addSocialEconomy',
    method: 'post',
    data
  })
}

export function updateSocialEconomy(data) {
  return request({
    url: '/SocialEconomy/updateSocialEconomy',
    method: 'post',
    data
  })
}

export function deleteSocialEconomy(ID) {
  return request({
    url: '/SocialEconomy/deleteSocialEconomy',
    method: 'get',
    params: { ID }
  })
}

export function getSocialEconomy(params) {
  return request({
    url: '/SocialEconomy/getSocialEconomy',
    method: 'get',
    params
  })
}

// 用户管理相关接口
export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

export function getUserInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

// 获取用户列表（支持分页和模糊查询）
export function getUserList(data) {
  return request({
    url: '/user/getUserList',
    method: 'post',
    data
  })
}
// 同步用户新数据
export function refreshUser() {
  return request({
    url: '/user/syncUser',
    method: 'get'
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: '/user/addUser',
    method: 'post',
    data
  })
}

// 更新用户信息
export function updateUser(data) {
  return request({
    url: '/user/updateUser',
    method: 'put',
    data
  })
}

// 删除用户
export function deleteUser(id) {
  return request({
    url: '/user/deleteUser',
    method: 'get',
    params: { id }
  })
}

// 获取所有院系数据（用于下拉框）
export function getDepartments() {
  return request({
    url: '/dept/list',
    method: 'get'
  })
}

// 根据ID获取用户详情
export function getUserById(id) {
  return request({
    url: `/user/${id}`,
    method: 'get'
  })
}
